package com.seafwg;

/**
 * @Author seafwg
 * @Date 2022/7/27 22:40
 * @Version 1.0
 * @Description 单例模式---懒汉式，线程安全
 */

public class SingletonModelUpdate {
}

/**
 * 线程安全的单例模式：懒汉是
 */
class SingletonDesigner{

    private static SingletonDesigner instance = null;

    private SingletonDesigner() {}

    public static SingletonDesigner getInstance() {
        if (instance == null) {
            // 效率比较低一些，在外层在添加判断效率较好，
            synchronized (SingletonDesigner.class) {
                if (instance == null) {
                    instance = new SingletonDesigner();
                }
            }
        }
        return instance;
    }
}